//
//  CarModleResultParser.m
//  QinghaiTourism
//
//  Created by QianXiaoShu on 16/3/29.
//  Copyright © 2016年 QianXiaoShu. All rights reserved.
//

#import "CarModleResultParser.h"
#import "CarMethods.h"
//模型
#import "ParserObjects.h"
#import "QHCarInfo.h"
@implementation AIRequest(Car)

-(void)carModuleHander:(id)responseObject responseData:(NSData *)responseData{

    DebugLog(@"responseObject->%@",responseObject);
    
    
    NSDictionary *result = [responseObject copy];
    
    if (!result || result.count == 0) {
        
        [self excuteBlock];
        return;
    }
    NSString *msg = [responseObject objectForKey:@"message"];
    self.result.message = msg;
    self.result.code = [responseObject objectForKey:@"result_code"];
    if ([self.result.code isEqualToString:@"0"]) {
        self.result.success = YES;
        
    }else{
        self.result.success = NO;
        
    }
    
    id dic = [DeviceUtility decryptUseDES:responseObject[@"result_data"] key:YQH_DESEncrypt_Key];
    
    
#pragma mark下面是［车辆模块］处理
    if ([self.method isEqualToString:_authentCarOfAction]) {
        NSLog(@"_authentCarOfAction_result%@",dic);
        
        
//        NSDictionary *registData = [dic getObject:@"QHSignup"];
//        
        [self excuteBlockWithObject:dic];
//        
        
    }
    if ([self.method isEqualToString:_myCarInfoOfAction]) {
       
        NSLog(@"解析_myCarInfoOfAction%@",dic);
      
        NSDictionary *carInfo = [dic getObject:@"QHCarInfo"];
       
            [self excuteBlockWithObject:carInfo];
        
    }
    if ([self.method isEqualToString:_getCarTypeList]) {
        
        NSLog(@"解析_myCarInfoOfAction%@",dic);
//        NSDictionary *carInfo = [dic getObject:@"QHCarInfo"];
//
//        
       [self excuteBlockWithObject:dic];
//

        
    }
    
    if ([self.method isEqualToString:_modifyBusinessOfAction]) {
        NSLog(@"解析_modifyBusinessOfAction%@",dic);
        ////商业险
//        
//        NSDictionary *object = [dic getObject:@"QHPersonObj"];
//        
       [self excuteBlockWithObject:dic];
//        
    }
    if ([self.method isEqualToString:_getDriverImgList]) {
        NSLog(@"解析_getDriverImgList%@",dic);
        ////商业险
        //
        //        NSDictionary *object = [dic getObject:@"QHPersonObj"];
        //
        [self excuteBlockWithObject:dic];
        //        
    }
    if ([self.method isEqualToString:_getAllMaintainProject]) {
        //字典数组--保养记录
        NSLog(@"解析_getAllMaintainProject%@",dic);
        NSArray *arr = (NSArray *)[dic mutableCopy];
        NSMutableArray *baoyang =[NSMutableArray array];

        
        if ([dic isKindOfClass:[NSArray class]]) {
        
                    for (int i = 0; i < arr.count; i++) {
                        [baoyang addObject:  arr[i][@"name"]];
                       
            
                    }
        }

        NSLog(@"baoyang->%@",baoyang);
        

        [self excuteBlockWithObject:baoyang];
    }
    if ([self.method isEqualToString:_deletePicture]) {
        
        NSLog(@"解析_deletePicture%@",dic);
        
        [self excuteBlockWithObject:dic];
        
        
        
    }
    
    if ([self.method isEqualToString:_addCarmaintainrecord]) {
      
        NSLog(@"解析_addCarmaintainrecord%@",dic);
        
        [self excuteBlockWithObject:dic];

        
        
    }
    if ([self.method isEqualToString:_vehicleReplacement]) {
        //更换车辆
        NSLog(@"解析_vehicleReplacement%@",dic);
        [self excuteBlockWithObject:dic];

       
    }
    else  {
        [self excuteBlock];
    }


}
@end
